$(function () {
    let form = layui.form
    form.verify({
        oldPwd: [
            /^[\S]{6,12}$/,
            '密码必须6到12位，且不能出现空格'
        ],
        newPwd: function (value) {
            let v1 = $('[name=oldPwd]').val()
            if (v1 === value) {
                return '新密码和旧密码不能一致'
            }
        },
        rePwd: function (value) {
            let v2 = $('[name=newPwd]').val()
            if (v2 !== value) {
                return '新密码和确认密码密码不一致'
            }
        }




    })
    $('#formPwd').on('submit', function (e) {
        e.preventDefault()
        axios({
            method: 'POST',
            url: '/my/updatepwd',
            data: $(this).serialize()
        }).then(res => {
            if (res.data.status !== 0) {
                return layui.layer.msg(res.data.message) 
            }
            layui.layer.msg('修改密码成功')
        console.log($('#formPwd'));
            $('#formPwd')[0].reset()
        })
  })


})